package com.goldsprite.microhorigame.ecs.fsms.states;

import java.util.ArrayList;
import java.util.List;

public class AnimatorShowState extends EntityState {
	private List<String> animList;
	private int nextIndex;

	@Override
	public void init() {
		animList = new ArrayList<>(fsm.getAnims().anims.keySet());
	}

	@Override
	public boolean canEnter() {
		return true;
	}

	@Override
	public boolean canExit() {
		return false;
	}

	@Override
	public void running() {
		if (fsm.getAnims().isAnimCompleted()) {
			nextIndex = ++nextIndex % animList.size();
			String nextAnim = animList.get(nextIndex);
			fsm.getAnims().playAnim(nextAnim);
		}
	}
}
